<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<head>
  <meta charset="UTF-8">
  <title>v-for</title>
</head>
<body>
<div id="app">
  <ul>
    <li v-for="it in arr">
      黑马程序员校区:{{it}}
    </li>
  </ul>
  <h2 v-for="it in vegetables">
    {{it.name}}
  </h2>
  <input type="submit" @click="add" value="增加">
  <input type="submit" @click="remove" value="减少">
</div>
<script>
  var app = new Vue({
    el: "#app",
    data: {
      arr: ["北京", "上海", "广州", "深圳"],
      vegetables: [
        {name: "西蓝花炒蛋"},
        {name: "蛋炒西蓝花"},
      ]
    },
    methods:{
      add:function () {
        this.vegetables.push({name:"花菜炒蛋"});
      },
      remove:function () {
        this.vegetables.shift();
      }
    }
  })
</script>
</body>
</html>
